package cn.yqx.bankshop.user.controller;

import cn.yqx.bankshop.result.Result;
import cn.yqx.bankshop.result.ResultCode;
import cn.yqx.bankshop.user.pojo.BuSupplier;
import cn.yqx.bankshop.user.service.OrderService;
import cn.yqx.bankshop.user.service.SupplierService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

@Slf4j
@RestController
@RequestMapping("/api/v1/supplier")
public class SupplierController {

    @Autowired
    SupplierService supplierService ;
    @Autowired
    OrderService orderService ;
    @RequestMapping(value = "/find_supplier" ,method = RequestMethod.GET)
    public Object findSupplierById(Long supplierId){
        BuSupplier buSupplier = supplierService.findSupplierById(supplierId) ;
        return  buSupplier ;
    }

    @RequestMapping(value = "/find_supplier_by_supplierId" ,method = RequestMethod.GET)
    public Object findSupplierBySupplierId(Long supplierId){
        Result result ;
        try{
            result = Result.success() ;
            BuSupplier buSupplier = supplierService.findSupplierById(supplierId) ;
            result.setData(buSupplier);
        }catch (Exception e){
            result = Result.failed(ResultCode.SYSTEM_EXECUTION_ERROR) ;
            log.error(" error : {} " , e );
        }

        return  result ;
    }

}
